<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div class="row" th:fragment="pagecom">
    <!--用于设置分野时后台用到的pageNum属性：将pageNum的值设置为1，默认为第一页，由于不用显示，用隐藏域设置即可-->
    <input type="hidden" name="pageNum" value="">
    <div class="col-sm-6">
        <div class="dataTables_info" id="DataTables_Table_0_info" role="alert"
             aria-live="polite" aria-relevant="all">
            当前第 <span th:text="${page.pageNum}"></span> 页，共<span
                th:text="${page.pages}"></span>页，共<span th:text="${page.total}"></span>数条据
        </div>
    </div>
    <div class="col-sm-6">
        <div class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate">
            <ul class="pagination">

                <li th:if="${page.hasPreviousPage}"
                    class="paginate_button previous"
                    aria-controls="DataTables_Table_0"
                    tabindex="0"
                    id="DataTables_Table_0_previous">
                    <!--点击该超链接后将class值为ec的form表单的value设置为1，并提交表单，相当于给表单设置了一个请求参数-->
                    <a th:href="'javascript:document.forms.ec.pageNum.value=1;document.forms.ec.submit();'">首页</a>
                </li>
                <li th:unless="${page.hasPreviousPage}"
                    class="paginate_button previous disabled"
                    aria-controls="DataTables_Table_0"
                    tabindex="0"
                    id="DataTables_Table_0_previous">
                    <!--href="javascript:;"点击改超链接无效-->
                    <a href="javascript:;">首页</a>
                </li>

                <li th:if="${page.hasPreviousPage}"
                    class="paginate_button previous" aria-controls="DataTables_Table_0"
                    tabindex="0"
                    id="DataTables_Table_0_previous">
                    <a th:href="'javascript:document.forms.ec.pageNum.value='+${page.prePage}+';document.forms.ec.submit();'">上一页</a>
                </li>
                <li th:unless="${page.hasPreviousPage}"
                    class="paginate_button previous disabled" aria-controls="DataTables_Table_0"
                    tabindex="0"
                    id="DataTables_Table_0_previous">
                    <a href="javascript:;">上一页</a>
                </li>

                <li th:each="i:${page.navigatepageNums}"
                    th:class="${page.pageNum==i?'paginate_button active':'oagubate_button'}"
                    tabindex="0">
                    <a th:href="'javascript:document.forms.ec.pageNum.value='+${i}+';document.forms.ec.submit();'"
                       th:text="${i}"
                    ></a>
                </li>

                <li th:if="${page.hasNextPage}"
                    class="paginate_button next" aria-controls="DataTables_Table_0" tabindex="0"
                    id="DataTables_Table_0_next">
                    <a th:href="'javascript:document.forms.ec.pageNum.value='+${page.nextPage}+';document.forms.ec.submit();'">下一页</a>
                </li>
                <li th:unless="${page.hasNextPage}"
                    class="paginate_button next disabled" aria-controls="DataTables_Table_0"
                    tabindex="0"
                    id="DataTables_Table_0_next">
                    <a href="javascript:;">下一页</a>
                </li>

                <!--尾页：与首页相同，也需要两个标签-->
                <li th:unless="${page.hasNextPage}"
                    class="paginate_button next disabled"
                    aria-controls="DataTables_Table_0"
                    tabindex="0"
                    id="DataTables_Table_0_next">
                    <a href="javascript:;">尾页</a>
                </li>
                <li th:if="${page.hasNextPage}" class="paginate_button next"
                    aria-controls="DataTables_Table_0" tabindex="0"
                    id="DataTables_Table_0_next">
                    <a th:href="'javascript:document.forms.ec.pageNum.value='+${page.pages}+';document.forms.ec.submit();'">尾页</a>
                </li>
            </ul>
        </div>
    </div>
</div>
</body>
</html>